package Raid;

import org.lwjgl.opengl.GL11;
import org.newdawn.slick.geom.*;
import org.newdawn.slick.opengl.Texture;


public class Laser {

	Environment env;
	
	float x;
	float y;
	float width = 8.0f;
	static float laserSpeed = .3f;
	static float laserLife = 1300;
	float age;
	
	double damage = 30.0;
	
	static Texture texture;
	float xSpeed;
	float ySpeed;
	Circle mask;
	
	int index;
	
	
	public Laser(Environment env, float startx, float starty, float xs, float ys, int index){
		this.env = env;
		x = startx;
		y = starty;
		xSpeed = xs;
		ySpeed = ys;
		this.index = index;
		age = 0;
		mask = new Circle(x-width/2.0f, y, width/2);
	}
	
	
	public void doLogic(int delta){
		x += xSpeed*laserSpeed*delta;
		y += ySpeed*laserSpeed*delta;
		age += delta;
		
		mask.setLocation(x-width/2.0f, y);
	}
	
	
	public Circle getMask(float xs, float ys){
		return new Circle(x + xs, y + ys, width);
	}
	
	
	public void render(){
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
		Laser.texture.bind();
		GL11.glBegin(GL11.GL_QUADS);
			GL11.glNormal3d(0, 0, 1);
			GL11.glTexCoord2d(0.0, 0.0);
			GL11.glVertex3i((int)(x-width/2), (int)y, 0);
			GL11.glTexCoord2d(1.0, 0.0);
			GL11.glVertex3i((int)(x+width/2), (int)y, 0);
			GL11.glTexCoord2d(1.0, 1.0);
			GL11.glVertex3i((int)(x+width/2), (int)(y+width), 0);
			GL11.glTexCoord2d(0.0, 1.0);
			GL11.glVertex3d((int)(x-width/2), (int)(y+width), 0);
		GL11.glEnd();
	}
	
	
	
	
	
	
	
	
}
